<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>jquery取得表单域的值</title>
<script src="jquery.min.js"></script>
</head>

<body>
获取radio的值-性别：
<input type="radio" value="male" name="gender" checked>男
<input type="radio" value="female" name="gender">女
<script type="text/javascript">
	var gender = $("input[name='gender']:checked").val();
	console.info(gender);
</script>
<br/>
获取checkbox的值-爱好：
<input type="checkbox" value="football" name="hobby" checked>足球
<input type="checkbox" value="billiards" name="hobby" checked>台球
<input type="checkbox" value="tennis" name="hobby" checked>网球
<script type="text/javascript">
	var hobbyStr="";
	$("input[name='hobby']:checked").each(function(){
		//hobbyStr+=$(this).val()+"\r\n";
		hobbyStr+=$(this).val()+",";
	});
	hobbyStr = hobbyStr.substring(0,hobbyStr.lastIndexOf(','));
	console.info(hobbyStr);
</script>
<br/>
获取select的值：key与value-来自:
<select name="fromplace">
	<option value="heilongjiang">黑龙江</option>
    <option value="jilin">吉林</option>
    <option value="辽宁">辽宁</option>
</select>
<script type="text/javascript">
	var selectText=$("select[name='fromplace']").find("option:selected").text(); 
	var selectValue=$("select[name='fromplace']").val();
	console.info(selectText);
	console.info(selectValue);
</script>
</body>
</html>
